import datetime
import os

from pathlib import Path

import pytest
from loguru import logger


def get_report_path():
    root_path = Path(__file__).parent
    report_path = root_path / 'reports'
    report_path.mkdir(exist_ok=True)
    time_smap = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
    task_dir = report_path / f'{time_smap}'
    task_dir.mkdir()
    log_path = task_dir / 'log'
    log_path.mkdir()
    log_file = log_path / 'pytest.log'
    logger.add(log_file)
    data_dir = task_dir / 'data'
    html_dir = task_dir / 'html'
    return data_dir, html_dir

def ding_talk():
    pass
def main():
    allure_dir, html_dir = get_report_path()

    pytest.main(['-sv', './test_flow', '--alluredir', str(allure_dir)])
    os.system(f'allure generate {allure_dir} -o {html_dir} --single-file')


if __name__ == '__main__':
    main()
